import React, { Component } from 'react'
import { Form, Input } from 'antd'
import PropTypes from 'prop-types'
/**
 * 添加分类的form组件
 */
const Item = Form.Item;

export default class AddForm extends Component {
    static propTypes = {
        setForm: PropTypes.func.isRequired, // 用来传递form对象的函数
    }

    componentWillMount() {
        this.props.setForm(this.props.form)
    }

    onFinish = (values) => {
        console.log('Received values from form: ', values);
    };

    render() {
        // 指定Item布局的配置对象
        const formItemLayout = {
            labelCol: { span: 4 },  // 左侧label的宽度
            wrapperCol: { span: 15 }, // 右侧包裹的宽度
        }
        return (
            <Form ref="form">
                <Item name="roleName" label='角色名称' {...formItemLayout} rules={[{ required: true, message: '请输入角色名称' }]}>
                    <Input placeholder="请输入角色名称"></Input>
                </Item>
            </Form>
        )
    }

}